<?php
class Wee_Logging_Block_Adminhtml_Details_Renderer_Diff extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract{
    public function render(Varien_Object $row){
        $html = '-';
        $columnData = $row -> getData($this -> getColumn() -> getIndex());
        $specialFlag = false;
        try{
            $dataArray = unserialize($columnData);
            if (is_bool($dataArray)){
                $html = $dataArray ? 'true' : 'false';
            }elseif (is_array($dataArray)){
                if (isset($dataArray['__no_changes'])){
                    $html = $this -> __('No changes');
                    $specialFlag = true;
                }
                if (isset($dataArray['__was_deleted'])){
                    $html = $this -> __('Item was deleted');
                    $specialFlag = true;
                }
                if (isset($dataArray['__was_created'])){
                    $html = $this -> __('N/A');
                    $specialFlag = true;
                }
                $dataArray = (array)$dataArray;
                if (!$specialFlag){
                    $html = '

';
                    foreach ($dataArray as $key => $value){
                        $html .= '
' . $key . '
    ' . $this -> htmlEscape($value) . '';
                    }
                    $html .= '

';
                }
            }else{
                $html = $columnData;
            }
        }
        catch (Exception $e){
            $html = $columnData;
        }
        return $html;
    }
}
